package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.RepairDetailInfo;
import com.pj.wisdomlogistics.mvp.contract.RepairDetailContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.RepairDetailModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;


public class RepairDetailPresenter extends ActivityPresenter<RepairDetailModel, RepairDetailContract.View> implements RepairDetailContract.Presenter {
    public static final String TAG = "RepairDetailPresenter";


    @Override
    public void findRepairDetail(int repairApplyID) {
        addSubscription(getModel().findRepairDetail(repairApplyID), new FilterSubscriber<RepairDetailInfo>() {
            @Override
            public void onNext(RepairDetailInfo mInfo) {
                getView().onSuccess(mInfo);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

        });
    }

    @Override
    public void orderRepair(String userID, int repairApplyID) {
        addSubscription(getModel().orderRepair(userID, repairApplyID), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onOrderSuccess();
            }
        });
    }

    @Override
    public void repairAllot(String userID, String fixWorkerID, String fixWorkerName, String fixWorkerTel, String repairApplyID, String comment, String state) {
        addSubscription(getModel().repairAllot(
                userID,
                fixWorkerID,
                fixWorkerName,
                fixWorkerTel,
                repairApplyID,
                comment,
                state), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onPoritionSuccess();
            }
        });
    }

    @Override
    public void assessRepair(String assess, String repairApplyID, int levels) {
        addSubscription(getModel().assessRepair(assess, repairApplyID, levels), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onPjSuccess();
            }
        });
    }


}
